import React, { useState,useEffect } from 'react';

export const CoutData: React.FC<any> = () => {
    const [user, setUser] = useState({
        name: "lkx",
        age: 19,
        address: "张家口"
    });
    const upData = ()=>{
        user.name="刘凯欣";
        setUser({...user});
        // 或者适用 Object.assign()
        // setUser(Object.assign({},user));
    }
    useEffect(()=>{
        console.log(user)
    },[user])
    return (
        <>
            <ol>
                <li>姓名值为:{user.name}</li>
                <li>年龄:{user.age}</li>
                <li>地址:{user.address}</li>
            </ol>
            <button onClick={upData}>修改名称</button>
        </>
    )
}